package cn.cuiliangpeng.basic.exception;

/** 系统错误码 **/
public enum ErrorCode {

    SYSTEM_ERROR("1001","系统内部异常"),
    ORDER_ERROR("1012","此订单正在进行中,请勿重复接单"),
    ORDER_ERROR2("1013","订单状态异常"),
    WX_ERROR("1011","微信内部错误"),
    PAGE_ERROR("1002","分页错误"),
    PASS_WORD("1003","密码错误"),
    PASS_WORD_ERROR("1008","二次密码错误"),
    USER_ERROR("1009","用户已注册"),
    USERNAME_ERROR("1010","用户不存在"),
    IMAGE_CODE_TIME_OUT("1005","图形验证码已过期,请重新获取"),
    IMAGE_CODE_ERROR("1006","图形验证码错误"),
    SMSCODE_ERROR("1007","请勿重新发送"),
    CONTENT_AUDIT_FAILED("1004","内容审核失败");

    //错误码
    private String code;
    //错误信息
    private String message;

    ErrorCode(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }
    public String getMessage() {
        return message+"["+code+"]";
    }

    public static ErrorCode getByCode(String code){
        //获取ErrorCode中所有对象的数组
        ErrorCode[] errorCodes = ErrorCode.values();

        for (ErrorCode errorCode : errorCodes) {
            if(errorCode.getCode().equals(code)){
                return errorCode;
            }
        }
        return null;
    }
}